package com.han.yrpc.core.consumer;

import com.han.yrpc.core.provider.YrpcProvider;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.stereotype.Component;

@Component
public class ConsumerBeanDefinitionPostProcessor implements BeanDefinitionRegistryPostProcessor {

    private final String BASE_PACKAGE = "com.han.yrpc";

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        ClassPathBeanDefinitionScanner definitionScanner = new ClassPathBeanDefinitionScanner(registry);
        definitionScanner.addIncludeFilter(new AnnotationTypeFilter(YrpcProvider.class));
        definitionScanner.scan(BASE_PACKAGE);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {

    }
}
